package com.zzyl.nursing.controller.member;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.nursing.dto.BoundFamlyDto;
import com.zzyl.common.core.domain.R;
import com.zzyl.nursing.dto.UserLoginRequestDto;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.nursing.vo.FamilyElderByPageVo;
import com.zzyl.nursing.vo.FamilyElderVo;
import com.zzyl.nursing.vo.LoginVo;
import com.zzyl.nursing.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 老人家属Controller
 * 
 * @author ruoyi
 * @date 2024-09-19
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "老人家属的接口")
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;


    @PostMapping("/login")
    @ApiOperation("小程序登录")
    public AjaxResult login(@RequestBody UserLoginRequestDto dto){
        LoginVo loginVo = familyMemberService.login(dto);
        return success(loginVo);
    }

    @PostMapping("/add")
    @ApiOperation("绑定家人")
    public AjaxResult boundFamly(@RequestBody BoundFamlyDto boundFamlyDto){
        familyMemberService.boundFamly(boundFamlyDto);
        return success();
    }
    @GetMapping("/my")
    @ApiOperation("查询家人列表")
    public AjaxResult familyElderList(){
        List<FamilyElderVo> familyElderVos = familyMemberService.familyElderList();
        return success(familyElderVos);
    }
    @GetMapping("/list-by-page")
    @ApiOperation("分页查询家人列表")
    public AjaxResult familyElderListByPage(Integer pageNum,Integer pageSize){
        Page<FamilyElderByPageVo> familyElderByPageVoPage = familyMemberService.familyElderListByPage(pageNum, pageSize);
        return success(familyElderByPageVoPage.getRecords());
    }



    @GetMapping("/queryDeviceDataListByDay")
    @ApiOperation("按天统计查询指标数据")
public R<List<ByDayVo>> QueryStatisticsByDay(String functionId, Long startTime, Long endTime, String iotId){
return R.ok(familyMemberService.QueryStatisticsByDay(functionId,startTime,endTime,iotId));
}

@GetMapping("/queryDeviceDataListByWeek")
    @ApiOperation("按周统计查询指标数据")
public R<List<ByDayVo>> QueryStatisticsByWeek(String functionId, Long startTime, Long endTime, String iotId){
return R.ok(familyMemberService.QueryStatisticsByWeek(functionId,startTime,endTime,iotId));
}


}
